package com.sh.threadmethod.createmethod.third;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Auther: sh
 * @Version 1.0
 * @Description:
 */
public class Third {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        FutureTask<String> futureTask = new FutureTask<>(new ThirdThread());
        Thread thread = new Thread(futureTask);
        thread.start();
        thread.start();
        String s = futureTask.get();   // 这里会阻塞，直到futureTask执行完毕
        System.out.println(s);
        System.out.println("main end");
    }
}

